//
//  WithdrawRecordTableViewCell.m
//  HWZB
//
//  Created by 许成雄 on 2017/4/24.
//  Copyright © 2017年 wonders. All rights reserved.
//

#import "WithdrawRecordTableViewCell.h"

@interface WithdrawRecordTableViewCell()

@property (strong, nonatomic) UILabel *timeLabel;
@property (strong, nonatomic) UIImageView *dividerImageView;
@property (strong, nonatomic) UIImageView *statusImageView;
@property (strong, nonatomic) UILabel *statusLabel;
@property (strong, nonatomic) UILabel *withdrawLabel;

@end

@implementation WithdrawRecordTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if(self) {
        self.timeLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, TRANS_VALUE(20.0f), TRANS_VALUE(66.0f), TRANS_VALUE(30.0f))];
        self.timeLabel.font = [UIFont systemFontOfSize:TRANS_VALUE(12.0f)];
        self.timeLabel.textColor = I_COLOR_BLACK;
        self.timeLabel.textAlignment = NSTextAlignmentCenter;
        [self.contentView addSubview:self.timeLabel];
        self.timeLabel.text = @"04-19";
        
        self.dividerImageView = [[UIImageView alloc] initWithFrame:CGRectMake(TRANS_VALUE(66.0f), TRANS_VALUE(0.0f), TRANS_VALUE(2.0f), TRANS_VALUE(70.0f))];
        self.dividerImageView.backgroundColor = I_COLOR_BACKGROUND;
        [self.contentView addSubview:self.dividerImageView];
        
        UIView *circleView = [[UIView alloc] initWithFrame:CGRectMake(TRANS_VALUE(64.0f), TRANS_VALUE(32.0f), TRANS_VALUE(6.0f), TRANS_VALUE(6.0f))];
        circleView.backgroundColor = I_COLOR_BACKGROUND;
        circleView.clipsToBounds = YES;
        circleView.layer.cornerRadius = TRANS_VALUE(6.0f) / 2;
        [self.contentView addSubview:circleView];
        
        self.statusImageView = [[UIImageView alloc] initWithFrame:CGRectMake(TRANS_VALUE(78.0f), TRANS_VALUE(22.0f), TRANS_VALUE(16.0f), TRANS_VALUE(16.0f))];
        self.statusImageView.contentMode = UIViewContentModeScaleAspectFit;
        self.statusImageView.image = [UIImage imageNamed:@"ic_record_mark"];
        [self.contentView addSubview:self.statusImageView];
        
        self.statusLabel = [[UILabel alloc] initWithFrame:CGRectMake(TRANS_VALUE(100.0f), TRANS_VALUE(20.0f), TRANS_VALUE(210.0f), TRANS_VALUE(20.0f))];
        self.statusLabel.font = [UIFont systemFontOfSize:TRANS_VALUE(12.0f)];
        self.statusLabel.textColor = I_COLOR_RED;
        self.statusLabel.textAlignment = NSTextAlignmentLeft;
        [self.contentView addSubview:self.statusLabel];
        self.statusLabel.text = @"已通过申请审核, 请耐心等待";
        
        self.withdrawLabel = [[UILabel alloc] initWithFrame:CGRectMake(TRANS_VALUE(74.0f), TRANS_VALUE(40.0f), TRANS_VALUE(236.0f), TRANS_VALUE(20.0f))];
        self.withdrawLabel.font = [UIFont systemFontOfSize:TRANS_VALUE(12.0f)];
        self.withdrawLabel.textColor = I_COLOR_BLACK;
        self.withdrawLabel.textAlignment = NSTextAlignmentLeft;
        [self.contentView addSubview:self.withdrawLabel];
        self.withdrawLabel.text = [NSString stringWithFormat:@"【已提现】￥%@元", @"200"];
        
    }
    return self;
}
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)setWithdrawRecordInfo:(WithdrawRecordInfo *)withdrawRecordInfo {
    _withdrawRecordInfo = withdrawRecordInfo;
    if(_withdrawRecordInfo) {
        NSString *dateStr = @"----";
        NSString *timeStr = _withdrawRecordInfo.refreshTime;
        if(timeStr != nil && timeStr.length == 19) {
            dateStr = [timeStr substringWithRange:NSMakeRange(5, 5)];
        }
        self.timeLabel.text = dateStr;
        if([_withdrawRecordInfo.state isEqualToString:@"1"]) {
            self.statusImageView.image = [UIImage imageNamed:@"ic_record_mark"];
            self.statusLabel.text = @"已完成";
            self.withdrawLabel.text = [NSString stringWithFormat:@"【已提现】￥%@元", _withdrawRecordInfo.money];
        } else {
            self.statusImageView.image = [UIImage imageNamed:@"ic_record_mark"];
            self.statusLabel.text = @"已通过申请审核, 请耐心等待";
            self.withdrawLabel.text = [NSString stringWithFormat:@"【正在提现...】提现￥%@元", _withdrawRecordInfo.money];
        }
    }
}

@end
